package de.gameduell.framework.facebook.reporting {

	import de.gameduell.framework.debug.Debug;
	import de.gameduell.framework.util.Tools;

	public class FBBaseTracker {

		public static var TRACKING_ENABLED:Boolean = true;
		private static var instance:FBBaseTracker;
		private var _tracker:WebtrekkObject;
		private var _appType:String;
		private var _enabled:Boolean;

		public static function getInstance():FBBaseTracker {
			if(instance == null) {
				instance = new FBBaseTracker();
			}
			return instance;
		}

		public function FBBaseTracker() {
			_enabled = TRACKING_ENABLED;
			_tracker = new WebtrekkObject();
		}
		
		public function set enabled(isEnabled:Boolean):void {
			_enabled = isEnabled;
		}

		public function track(trackingInfo:String):void {
			Debug.trace("FBBaseTracker::track: " + trackingInfo + " tracking enabled -> " + TRACKING_ENABLED, Debug.DEBUG);
			_tracker.contentId = trackingInfo;
			if(_enabled){
				Debug.trace("FBBaseTracker::track: -> " + trackingInfo, Debug.DEFAULT);
				Tools.callJavaScript("track", _tracker.toJSON());
			}
		}
		
		public function get tracker():WebtrekkObject {
			return _tracker;
		}

		public function set customerId(anID:String):void {
			_tracker.customerId = anID;
		}
		
		public function set appContext(anAppContext:String):void {
			_tracker.appContext = anAppContext;
		}
		
		public function get appType():String {
			return _appType;
		}
		
		public function set appType(anAppType:String):void {
			_tracker.appType = anAppType;
		}
	}
}
